<?php

namespace app\api\model\mysql;

use app\common\model\TimeModel;

class MallOrderGoods extends TimeModel
{
    public function getByOrderGoodsList($id,$field='*'){
        return $this->field($field)
            ->where("order_id",$id)
            ->select()
            ->toArray();
    }

    /**
     *
     * @param $value
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    protected function getGetSpecsValueAttr($value){
        if(empty($value)){
            return '';
        }
        $ids = explode("-",$value);
        $res= (new MallSpecsValue())->where('id','in',$ids)
            ->select()->toArray();
        return array_column($res,'title');
    }
}